﻿@{
    ViewBag.Title = "newsList";
}

<div id="cphMain_ctl00_ContentPane" class="center">
    <div id="Breadcrumb" class="Breadcrumb">
        <ul>
            <li class="first">
                <a href='javascript:;' onclick="javascript:loadAction('Index2','Main')">Trang chủ
                </a>
            </li>
            <li>
                <a href='javascript:;' onclick="javascript:loadAction('personal','Account')">Tài khoản của tôi
                </a>
            </li>
            <li>
                <span>Danh sách tin tức</span>
            </li>
        </ul>
    </div>

    <div class="Account-Module DefaultModule">

        <div class="Block DefaultModule">


            <div id="CartHeader" class="Block Moveable Panel">
                <h2>Danh sách tin tức
                </h2>
            </div>

            <div id="CartContainer" class="Block Moveable Panel">
                @if (Model != null)
                { 
                    <div class="BlockContent">

                        <div class="Clear">
                            <div class="FloatRight">
                                <a href="javascript:;" onclick="javascrip:loadAction('newsView','Admin')"
                                    class="myBtn1">Thêm bài mới</a>
                            </div>
                        </div>

                        <div class="Clear">
                        </div>

                        <div>
                            <div>

                                <table class="CartContents" cellspacing="0" rules="rows" border="1"
                                    id="cphMain_ctl00_ctl01_ctl00_grvList" style="width: 100%; border-collapse: collapse;">
                                    <tbody>
                                        <tr class="even-row">
                                            <th scope="col" style="text-align: left">Tiêu đề
                                            </th>
                                            <th scope="col" style="text-align: left">Ngày gửi
                                            </th>
                                            <th scope="col">&nbsp;</th>
                                        </tr>
                                        @{var rowCount = 0; string cssRowClass = "";}
                                        @foreach (var news in Model)
                                        {
                                            if (++rowCount % 2 == 1) { cssRowClass = "old-row"; }
                                            else { cssRowClass = "even-row"; }
                                            <tr class="@cssRowClass">
                                                <td>
                                                    <a href="javascript:;" onclick="javascript:loadActionData('newsView','Admin','ID=@news.ID')">
                                                        <strong>@news.title</strong></a>
                                                    <br>
                                                </td>
                                                <td>
                                                    @news.post_date
                                                </td>
                                                <td style="width: 1px;">
                                                    <a href="javascript:;" onclick="javascript:deleteNews(@news.ID)" class="myBtn1">Xóa</a>
                                                </td>
                                            </tr>
                                        }
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>

                    <div class="PageNavigation" style="padding-bottom: 10px; padding-top: 10px;" align="center">
                        @{var previousPage = Math.Max(ViewBag.currentPage - 1, 1);}
                        <a  href="javascript:;" onclick="javascript:loadActionData('newsList','Admin','pageNum=@previousPage')">&lt;&lt;</a>
                        @for (int num = 1; num <= ViewBag.maxPage; num++)
                        {
                            if (ViewBag.currentPage == num)
                            {
                            <a class="active" href="#"
                                style="background-color: gray; color: white;"><strong>@num</strong></a>
                            }
                            else
                            {
                            <a  href="javascript:;" onclick="javascript:loadActionData('newsList','Admin','pageNum=@num')">@num</a>    
                            }
                        }
                        @{var nextPage = Math.Min(ViewBag.maxPage, ViewBag.currentPage + 1);}
                        <a href="javascript:;" onclick="javascript:loadActionData('newsList','Admin','pageNum=@nextPage')">&gt;&gt;</a>
                    </div>
                }else
                {
                    <div class="BlockContent">
                        <div class="Clear">
                            <div class="FloatRight">
                                <a href="javascript:;" onclick="javascrip:loadAction('newsView','Admin')"
                                    class="myBtn1">Thêm bài mới</a>
                            </div>
                        </div>
                        <h1>Không có bài viết nào</h1>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
